//************************************************
//  *Author：jxx
//  *QQ：283591387
//  *自定义业务逻辑扩展
//************************************************
import { mapMutations } from 'vuex';
import extend from './q_operations_returnExtend.js';
import options from './q_operations_returnOptions.js';
import detailOptions from '../q_operations_returnList/q_operations_returnListOptions.js';
export default function () {
	return {
		data() {
			let _options = options();
			_options.extend = extend;
			_options.detailOptions = detailOptions();
			return {
				options: _options,
			};
		},
		methods: {
			...mapMutations(['setSalesContractDataStore', 'setPageIDStore']),
			onInited() {
				//页面参数初始化
				//设置table超出换行显示
				//this.textInline = false;

				//设置列宽度
				//this.columns[1].width = 70;

				//设置table为水平显示或者list列表显示
				//this.direction = 'horizontal'//list
				//如果为list列表显示，指定list的标题列
				//this.titleField="字段";
				//页面打开时禁用加载数据
				//this.load=false;
				//页面打开时默认弹出查询框
				//this.searchModel = true;
				this.editFormOptions.forEach((item) => {
					if (item.field == 'Fittings_delivery_sub') {
						item.testVal = '点击选择运维发货单';
						item.required = true;
						item.focusUrl = '/operationsinfo/q_fittings_delivery/q_fittings_delivery';
						// item.onFocus=(e)=>{
						// 	console.log("this.editFormFields",this.editFormFields);
						// 	uni.navigateTo({
						// 		url:"/operationsinfo/q_fittings_delivery/q_fittings_delivery"
						// 	})
						// }
					}
				});
			},
			formatter(row, column, index) {
				//自定义格式化
			
				return '';
			},
			rowClick(index, row, column) {
				//行点击事件(默认触发编辑)
				//行点击事件(默认触发编辑)
				this.setPageIDStore(row.Operations_return);
				let url = '/operationsinfo/q_operations_return/Detail/Detail?operationsinfo=' + row.Operations_return;
				uni.navigateTo({
					url: url
				});
				return false;
				// return true;
			},
			cellClick(index, row, column) {
				//单元格击事件(默认触发编辑)
				//仅onInited中设置：this.direction = "horizontal", this.columns的字段设置为click=true后生效
				return true;
			},
			rowButtons(index, row) {
				//列表显示的按钮
				
				if (row.AuditStatus === 0) {
					return [
						{
							text: '审核',
							type: 'error',
							shape: 'circle'
						},
						{
							text: '编辑',
							type: 'warning',
							shape: 'circle'
						}
					];
				}
				//返回查看审批按钮
				return [
					{
						text: '查看审核',
						type: 'primary',
						shape: 'circle'
					}
				];
			},
			rowButtonClick(btn, index, row) {
				//列表显示的按钮点击事件
				//    if(btn.text=='删除'){
				// 	this.$toast('删除')
				// }
				if (btn.text == '编辑') {
					uni.setStorageSync('q_operations_return', row);
					const optionsObj = {
						// editFormFields: this.options.editFormFields,
						editFormOptions: this.options.editFormOptions,
						detailColumns: this.options.detailOptions.columns,
						detailtable: this.options.table
					};
					uni.setStorageSync('optionsObj', JSON.stringify(optionsObj));
					uni.navigateTo({
						url: '/pages/addPage/addPage?biaoming=q_operations_return&&currentAction=Update&&ID=Operations_return&&zibiaoming=q_operations_return_not'
					});
					return;
				}
				this.setSalesContractDataStore({ workTable: 'q_operations_return', tableKey: row.Operations_return });
				try {
					uni.navigateTo({
						url: `/operationsinfo/q_operations_return/q_operations_returnAduit?workTable=q_operations_return&&tableKey=` + row.Operations_return
					});
				} catch (e) {
					console.log(e);
				}
			},
			searchBefore(params) {
				//查询前
				return true;
			},
			updateBefore(formData) {
				//更新保存前操作
				return true;
			},
			addBefore(formData) {
				//新建保存前操作
				return true;
			},
			searchFormOnChange(field, value) {
				//查询弹出框下拉框或日期选中事件
				//if(field=="字段"){
				// 	console.log(value)
				//}
			},
			editFormOnChange(field, value) {
				//新建编辑弹出框下拉框或日期选中事件
				//if(field=="字段"){
				// 	console.log(value)
				//}
			}
		}
	};
}
